home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 137 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.8 KB

  1. From: mtimmerm@microstar.com (Matt Timmermans)
  2. Message-ID: <4e85k6$b04@noc.tor.hookup.net>
  3. X-Original-Date: Thu, 25 Jan 1996 14:55:49 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 25 Jan 96 16:01:45 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Why no allocator-specific delete?
  9. Organization: Microstar Software Ltd.
  10. References: <4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM>
  11. X-Newsreader: Forte Free Agent v0.55
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMQepg+EDnX0m9pzZAQEQGQGAgm4V0AUcqpHmhX1mBTwxP9J9LAf53TSb
  14.     hJ0PO66jEniIvix9ll0x1hUIsBQSgc3b
  15.     =j1mC
  16.  
  17. (clamage@Eng.Sun.COM (Steve Clamage))
  18.  
  19. |   In article 460@news.bridge.net, David Byrden <100101.2547@compuserve.com>
  20. |   writes:
  21. |   >Why, in the Septenber draft standard, is an allocator-specific verrion
  22. |   >of 'new' provided;
  23. |   >
  24. |   >20.1.4.4
  25. |   >
  26. |   >           new(x) T    
  27. |   >
  28. |   >    returns an X::types<T>::pointer, where x is of an 
  29. |   >    allocator type X
  30.  
  31. |   You are actually referring to the "placement new" syntax not having a
  32. |   corresponding "placement delete" syntax.
  33.  
  34. Yes, and this is very annoying.  The lack of a placement-delete makes
  35. placement-new nearly useless.  I can't, in fact, think of a single way that
  36. placement-new could be used properly.
  37.  
  38.  
  39. |   No good syntax was found for such. The obvious syntax
  40. |       delete (x) p;
  41. |   leads to too many ambiguities. More importantly, it means that the
  42. |   point of deletion would somehow have to know what placement version
  43. |   of "new" was used and what the parameters were. Needing that knowledge
  44. |   would make "placement delete" unsafe and hard to use. (Consider the
  45. |   general case where the "new" and "delete" expressions are in different
  46. |   compilation units, and the parameters to "new" affect how "delete"
  47. |   should be called.)
  48.  
  49.  
  50. The caller of 'delete' already has to know the allocation policy of the
  51. object -- otherwise it would not know that it was safe to delete.  Further,
  52. we already do this sort of thing all the time -- but we have to code it
  53. explicitly, i.e., remove object from collection, delete object.
  54.  
  55. The lack of a placement-delete is on of the many factors in C++ conspiring
  56. to make it absolutely impossible to make generic collections that hold
  57. actual objects (with constructors) instead of just pointers.
  58.  
  59.  
  60. </Matt>
  61.  
  62. --------------------------------------------------------------
  63. Matt Timmermans               | Phone:  +1 613 596-2233
  64. Microstar Software Ltd.       | Fax:    +1 613 596-5934
  65. 3775 Richmond Rd.             | E-mail: mtimmerm@microstar.com
  66. Nepean Ontario CANADA K2H 5B7 | http://www.microstar.com
  67. ---
  68. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  69.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  70.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  71.